#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 24;

int n, m;
vector<int> a(24, 0);
vector<int> path;
int b[8][7] = {{0, 2, 6, 11, 15, 20, 22},    {1, 3, 8, 12, 17, 21, 23},
               {10, 9, 8, 7, 6, 5, 4},       {19, 18, 17, 16, 15, 14, 13},
               {23, 21, 17, 12, 8, 3, 1},    {22, 20, 15, 11, 6, 2, 0},
               {13, 14, 15, 16, 17, 18, 19}, {4, 5, 6, 7, 8, 9, 10}};
string ops = "ABCDEFGH";
int ib[8] = {5, 4, 7, 6, 1, 0, 3, 2};  // inverse ops
int c[8] = {6, 7, 8, 11, 12, 15, 16, 17};
int d;
int f(vector<int>& a) {
  int cnt[4] = {0};
  rep(i, 0, 7) { cnt[a[c[i]]]++; }
  int res = 8;
  rep(i, 1, 3) res = min(res, 8 - cnt[i]);
  return res;
}
void mov(int id) {
  vector<int> t;
  rep(i, 1, 6) t.push_back(a[b[id][i]]);
  t.push_back(a[b[id][0]]);
  rep(i, 0, 6) a[b[id][i]] = t[i];
}
bool dfs(int u) {
  int h = u + f(a);
  if (h > d) return false;
  if (u == d) return true;
  rep(i, 0, 7) {
    vector<int> b = a;
    mov(i);
    path.push_back(i);
    if (dfs(u + 1)) return true;
    path.pop_back();
    mov(ib[i]);
  }
  return false;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  while (cin >> a[0] && a[0]) {
    rep(i, 1, 23) cin >> a[i];
    path.clear();
    d = 0;
    while (!dfs(0)) d++;
    if (d == 0) {
      cout << "No moves needed" << endl;
    } else {
      for (int i : path) cout << ops[i];
      cout << endl;
    }
    cout << a[6] << endl;
  }
  return 0;
}